package com.service;
import com.huawei.demo.Demo;
import lombok.extern.slf4j.Slf4j;
import com.object.Result;

import java.sql.SQLOutput;
import java.util.Random;
import java.util.Scanner;

@Slf4j
public class ResultOperationlmp implements ResultOperation {
    public static int count(int a)
    {
        a++;
        return a;
    }
    //public static int playerWinNumber = 0;
    public Result gameStandard () {
        Random random = new Random();
        ResultOperationlmp count = new ResultOperationlmp();
        ResultOperationlmp s = new ResultOperationlmp();//调用ResultOperationlmp的数据
        Demo D = new Demo();
        Scanner input = new Scanner(System.in);//调用输入
        int playerWinNumber = 0;
        int computerWinNumber = 0;
        int dogfallNumber = 0;
        for (int i = 1; i <= 5; i++) {
            System.out.println("第" + i + "局");
            int coumputer = random.nextInt(3) + 1;
            String uer = input.next();
            //Result a = s.gameStandard(person);//调用ResultOperationlmp结果
            int person = 0;//保证person - coumputer + 3) % 3不为0，1，2
            if (uer.equals("石头")) {
                person = 3;
                log.info("你出的是"+uer);
            } else if (uer.equals("剪刀")) {
                person = 2;
                log.info("你出的是"+uer);
            } else if (uer.equals("布")) {
                person = 1;
                log.info("你出的是"+uer);
            } else if((!uer.matches("石头|剪刀|布"))){
                log.info("输入错误");
                log.info("这局不算*@-@*");
            }

            //int coumputer = random.nextInt(3) + 1;
            Result result = new Result();
            if (person != 0) {
                switch ((person - coumputer + 3) % 3) {
                    case 0:
                        //result = rockPaperScissorsByPersonandComputerDraws();
                        if (coumputer == 1) {
                            log.info("电脑输出的是布");
                        }
                        if (coumputer == 2) {
                            log.info("电脑输出的是剪刀");
                        }
                        if (coumputer == 3) {
                            log.info("电脑输出的是石头");
                        }
                        //log.info(String.valueOf(result));
                        log.info("这一局平局！");
                        dogfallNumber++;
                        //1 - 1, 2 - 2, 3 - 3
                        break;
                    case 1:
                        //rockPaperScissorsByPersonWin(playerWinNumber);
                        if (coumputer == 1) {
                            log.info("电脑输出的是布");
                        }
                        if (coumputer == 2) {
                            log.info("电脑输出的是剪刀");
                        }
                        if (coumputer == 3) {
                            log.info("电脑输出的是石头");
                        }
                        //log.info(String.valueOf(result));
                        log.info("这一局你赢了！");
                        playerWinNumber ++;
                        //2 - 1, 3 - 2,
                        break;
                    case 2:
                        //result = rockPaperScissorsByComputerWin();
                        if (coumputer == 1) {
                            log.info("电脑输出的是布");
                        }
                        if (coumputer == 2) {
                            log.info("电脑输出的是剪刀");
                        }
                        if (coumputer == 3) {
                            log.info("电脑输出的是石头");
                        }
                        //log.info(String.valueOf(result));
                        log.info("这一局电脑获胜！");
                        computerWinNumber++;
                        break;
                }
            }
            //log.info(String.valueOf(a));
            //return result;
        }
        log.info("你本轮游戏：赢了"+playerWinNumber+"局 平了"+dogfallNumber+"局 输了"+computerWinNumber+"局");
        return null;
    }


    @Override
    public int rockPaperScissorsByPersonWin(int s) {
        //Result result = new Result();
        //result.setPersonWin(result.getPersonWin() + 1);
        s ++;
        return s;
    }

    @Override
    public Result rockPaperScissorsByComputerWin() {
        Result result = new Result();
        result.setComputerWin(result.getComputerWin() + 1);
        return result;
    }


    @Override
    public Result rockPaperScissorsByPersonandComputerDraws() {
        Result result = new Result();
        result.setPersonandComputerDraws(result.getPersonandComputerDraws() + 1);
        return result;
    }

    @Override
    public Result gameStandard(String person, int computer) {
        return null;
    }
}
